var div = $("div");
div.attr("foo", "bar");
var pass = true;
for ( var i = 0; i &lt; div.size(); i++ ) {
  if ( div.get(i).getAttribute('foo') != "bar" ) pass = false;
}
ok( pass, "Set Attribute" );